import {BasicColumn} from '/@/components/Table';
import {FormSchema} from '/@/components/Table';
import { rules} from '/@/utils/helper/validator';
import { render } from '/@/utils/common/renderUtils';
//列表数据
export const columns: BasicColumn[] = [
   {
    title: '创建人',
    align:"center",
    dataIndex: 'createBy'
   },
   {
    title: '创建日期',
    align:"center",
    sorter: true,
    dataIndex: 'createTime'
   },
   {
    title: '更新日期',
    align:"center",
    sorter: true,
    dataIndex: 'updateTime'
   },
   {
    title: '名称',
    align:"center",
    dataIndex: 'name'
   },
   {
    title: '位置',
    align:"center",
    dataIndex: 'position'
   },
   {
    title: '所属线路',
    align:"center",
    dataIndex: 'lineId_dictText'
   },
   {
    title: '使用寿命',
    align:"center",
    dataIndex: 'usefulLife'
   },
   {
    title: '图片',
    align:"center",
    dataIndex: 'imgString'
   },
  {
    title: '型号',
    align:"center",
    dataIndex: 'model'
  },
];
//查询数据
export const searchFormSchema: FormSchema[] = [
     {
      label: "名称",
      field: "name",
      component: 'Input', //TODO 范围查询
      //colProps: {span: 6},
	},
	{
      label: "所属线路",
      field: 'lineId',
      component: 'JDictSelectTag',
      componentProps:{
          dictCode:"yc_line,name,id"
      },
      //colProps: {span: 6},
 	},
];
//表单数据
export const formSchema: FormSchema[] = [
  {
    label: '名称',
    field: 'name',
    component: 'Input',
    dynamicRules: ({model,schema}) => {
          return [
                 { required: true, message: '请输入名称!'},
          ];
     },
  },
  {
    label: '位置',
    field: 'position',
    component: 'Input',
  },
  {
    label: '所属线路',
    field: 'lineId',
    component: 'JDictSelectTag',
    componentProps:{
        dictCode:"yc_line,name,id"
     },
    dynamicRules: ({model,schema}) => {
          return [
                 { required: true, message: '请输入所属线路!'},
          ];
     },
  },
  {
    label: '使用寿命',
    field: 'usefulLife',
    component: 'Input',
    dynamicRules: ({model,schema}) => {
          return [
                 { required: true, message: '请输入使用寿命!'},
          ];
     },
  },
  {
    label: '图片',
    field: 'imgString',
     component: 'JImageUpload',
     componentProps:{
      },
  },

	// TODO 主键隐藏字段，目前写死为ID
	{
	  label: '',
	  field: 'id',
	  component: 'Input',
	  show: false
	},
];

// 高级查询数据
export const superQuerySchema = {
  createBy: {title: '创建人',order: 0,view: 'text', type: 'string',},
  createTime: {title: '创建日期',order: 1,view: 'datetime', type: 'string',},
  updateTime: {title: '更新日期',order: 2,view: 'datetime', type: 'string',},
  name: {title: '名称',order: 3,view: 'text', type: 'string',},
  position: {title: '位置',order: 4,view: 'text', type: 'string',},
  lineId: {title: '所属线路',order: 5,view: 'list', type: 'string',dictTable: "yc_line", dictCode: 'id', dictText: 'name',},
  usefulLife: {title: '使用寿命',order: 6,view: 'text', type: 'string',},
  img: {title: '图片',order: 7,view: 'image', type: 'string',},
  tes: {title: '测试',order: 8,view: 'markdown', type: 'string',},
};

/**
* 流程表单调用这个方法获取formSchema
* @param param
*/
export function getBpmFormSchema(_formData): FormSchema[]{
  // 默认和原始表单保持一致 如果流程中配置了权限数据，这里需要单独处理formSchema
  return formSchema;
}
